|
|
|
|
|
|
|
The Methods of the Database Object |
|
|
|
|
|
|
|
|
The Database object has 11 methods, but we won't cover all of them here. Table 9.4 shows the Database object methods grouped in a logical fashion. |
|
|
|
|
| Table 9.4. The Database object methods. | | Group | Methods | | Replication | MakeReplica, PopulatePartial, Synchronize | | Security | NewPassword | | Child Objects | CreateQueryDef, CreateTableDef, CreateRelation | | Database Objects | OpenRecordset, Execute, CreateProperty, Close |
|
|
|
|
|
|
You'll learn about the Security methods in Day 20 and the NewPassword method is covered in Day 21. The Child Object methods are covered later in this chapter. That leaves the OpenRecordset, Execute, CreateProperty, and Close methods for review here. |
|
|
|
|
|
|
|
|
The OpenRecordset Method of the Database Object |
|
|
|
|
|
|
|
|
You use the OpenRecordset method to access data in existing tables in the database. You can use OpenRecordset to create Dynaset, Snapshot, or Table data objects. |
|
|
|
|
|
|
|
|
The format of the OpenRecordset method is as follows: |
|
|
|
|
|
|
|
|
Set Variable = Database.OPENRECORDSET(Source, Type, options) |
|
|
|
|
|
|
|
|
In this syntax, Database is the name of the database that will be used to create the Recordset. Type indicates whether the Recordset created is a Table (dbOpenTable), a Dynaset (dbOpenDynaset), or a Snapshot (dbOpenSnapshot). A Table type is created if you don't specify a type. You can also add options for security and record viewing. See Visual Basic online help for a complete description of these options. |
|
|
|
|
|
|
|
|
Add a new command button to the project. Set its Name property to cmdOpenRS and its Caption property to. Add the code in Listing 9.11 in the cmdOpenRS_Click code window. |
|
|
|
|
|
|
|
|
Listing 9.11. Coding the cmdRecordset_Click event. |
|
|
|
|
|
|
|
|
Private Sub cmdOpenRS_Click()
'
' open record sets
' |
|
|
|
|
|